<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateShopDistributionBillRecord extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shop_distribution_bill_record', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger("shopId")->default(0)->comment("店铺ID");
            $table->unsignedBigInteger("distributionId")->default(0)->comment("渠道ID");
            $table->unsignedInteger('settlementCycleTime')->default(0)->comment('结算日期');
            $table->unsignedInteger('amount')->default(0)->comment('实收金额：分');
            $table->unsignedInteger('brokerage')->default(0)->comment('佣金：分');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");

            $table->comment = '店铺分销分佣记录表';
            $table->index('shopId', 'idx_shopId');
            $table->index('distributionId', 'idx_distributionId');
            $table->index('settlementCycleTime', 'idx_settlementCycleTime');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('shop_distribution_bill_record');
    }
}
